Skip to content

fix(table-core): reset expansion when data changes - #6443

Closed
KevinVandy wants to merge 1 commit into
betafrom
agent/fix-5801-auto-reset-expanded
Closed

fix(table-core): reset expansion when data changes#6443
KevinVandy wants to merge 1 commit into
betafrom
agent/fix-5801-auto-reset-expanded

Conversation

@KevinVandy

Copy link
Copy Markdown
Member

Closes #5801

Decision

This remains a valid, narrowly scoped bug in the latest v9 beta. The existing automatic expansion reset is attached to the grouped row-model stage, so it happens only when grouping support is installed. A table using row expansion without grouping retains stale expanded row IDs after its data reference changes, despite the autoResetExpanded option contract.

This is not a new API or a behavior redesign. It connects the existing reset helper to the core data-dependent row model, alongside the existing automatic page-index reset.

Changes

  • run the existing expanded-state auto-reset after the core row model recomputes for a new data reference
  • add an end-to-end regression test using expansion without the grouping feature
  • retain the existing autoResetAll, autoResetExpanded, manualExpanding, initial-state, and controlled-state updater semantics

Verification

  • regression test fails on beta before the implementation change, retaining the expanded row ID
  • table-core focused auto-reset suite: 22 tests passed
  • full table-core suite: 52 files and 1,005 tests passed
  • TypeScript source and declaration-emit checks passed
  • ESLint passed for changed files
  • Prettier check passed for changed files

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5813e0fd-0154-46ee-84fd-b920e2142181

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/fix-5801-auto-reset-expanded

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nx-cloud

nx-cloud Bot commented Jul 18, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 0b815c9

Command Status Duration Result
nx affected --targets=test:eslint,test:sherif,t... ❌ Failed 5m 23s View ↗
nx run-many --targets=build --exclude=examples/** ✅ Succeeded 51s View ↗

☁️ Nx Cloud last updated this comment at 2026-07-18 00:43:33 UTC

@pkg-pr-new

pkg-pr-new Bot commented Jul 18, 2026

Copy link
Copy Markdown
More templates

@tanstack/alpine-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/alpine-table@6443

@tanstack/angular-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/angular-table@6443

@tanstack/angular-table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/angular-table-devtools@6443

@tanstack/ember-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/ember-table@6443

@tanstack/lit-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/lit-table@6443

@tanstack/match-sorter-utils

npm i https://pkg.pr.new/TanStack/table/@tanstack/match-sorter-utils@6443

@tanstack/preact-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/preact-table@6443

@tanstack/preact-table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/preact-table-devtools@6443

@tanstack/react-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/react-table@6443

@tanstack/react-table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/react-table-devtools@6443

@tanstack/solid-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/solid-table@6443

@tanstack/solid-table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/solid-table-devtools@6443

@tanstack/svelte-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/svelte-table@6443

@tanstack/table-core

npm i https://pkg.pr.new/TanStack/table/@tanstack/table-core@6443

@tanstack/table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/table-devtools@6443

@tanstack/vue-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/vue-table@6443

@tanstack/vue-table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/vue-table-devtools@6443

commit: 0b815c9

Comment on lines +30 to +31
table_autoResetExpanded(table)
table_autoResetPageIndex(table)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use batchfrom reactivity here I think, or move the batch invocation into onAfterUpdate 🤔

KevinVandy added a commit that referenced this pull request Aug 2, 2026
…d guard first runs (#6499)

Auto-resets are `onAfterUpdate` hooks on the row model stage memos. Two
related defects made them fire in the wrong places.

Expansion auto-reset was only wired from the grouped row model, so
`autoResetExpanded` silently did nothing for tables that use expansion
without grouping (#5801). It is now wired from `createCoreRowModel`
alongside the existing pageIndex, sorting, and cell-selection resets, so
a data reference change resets expansion regardless of which features are
installed. `table_autoResetExpanded` gained the same feature guard the
sorting and cell-selection resets already use, since the core row model
runs on tables without the expanding feature.

Auto-resets also fired on the very first computation of every stage
(#5968). `memo` seeds its dependency list to `[]`, so the initial run
always compares as changed, and merely reading a row model on mount
scheduled resets. For uncontrolled tables this was self-cancelling (the
reset targets `initialState`), which is why it went unnoticed, but it
wiped a seeded `initialState.pagination.pageIndex` and pushed unsolicited
`onExpandedChange` / `onPaginationChange` calls at controlled consumers on
mount. v7 and v8 suppressed the first run with a `registered` flag; the
v9 rewrite dropped it.

A new `skipFirstRun` util restores that suppression. It is applied in the
row model factories, which already run once per table, so each table gets
its own flag. The grouped row model tracked previous inputs already and
only needed its first-run condition inverted. The worker bridge reports
every stage as changed in its first response, so it carries an equivalent
`hasAppliedResults` flag.

Landing order matters: wiring expansion into the core row model without
the first-run guard would have extended the mount-time wipe from grouped
tables to every table using expansion, so both halves ship together.

- fix: wire `table_autoResetExpanded` into `createCoreRowModel` (#5801)
- fix: skip auto-resets on the first computation of each stage (#5968)
- add `skipFirstRun` util; apply to core, filtered, and sorted row models
- invert the grouped row model's first-run condition
- guard `table_autoResetExpanded` when the expanding feature is absent
- skip auto-resets on the worker bridge's first applied result
- tests: expansion reset without the grouping feature; first-run guard
  suite covering seeded initial state and controlled-state consumers

Examples: migrate the basic examples to `createColumnHelper` across all
frameworks, document more table options inline as commented-out defaults,
and replace the `filterFns.between` workaround in the React expanding
example with the `filterFn_between` individual export that already
existed.

Closes #5801
Closes #5968
Supersedes #6443

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
@KevinVandy KevinVandy closed this Aug 2, 2026
@KevinVandy
KevinVandy deleted the agent/fix-5801-auto-reset-expanded branch August 4, 2026 04:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

autoResetExpanded not reset the expanded state on data change in V8

2 participants